<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%
String path = request.getContextPath();
 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
		<title></title>
		<meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
		<link rel="stylesheet" type="text/css" href="<c:url value="/static/jquery-easyui/themes/default/easyui.css"/>">
		<link rel="stylesheet" type="text/css"
			href="<c:url value="/static/jquery-easyui/themes/icon.css"/>">
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/jquery-1.6.min.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/jquery.easyui.min.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/jsp/base/queryCode.js"/>"></script>
		<script type="text/javascript" src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
		<script type="text/javascript" src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>		
		<script type="text/javascript" >	
			function initList(listDisplayEId) {
				$('#' + listDisplayEId).datagrid(
						{
							nowrap : false,
							striped : true,
							collapsible : true,
							remoteSort : false,
							notSelectByRow : false,
						/* 	frozenColumns : [ [ {
								field : 'ids',
								checkbox : true
							} ] ], */
							toolbar : [
									{
										id : listDisplayEId + '_btn_add',
										text : '新增',
										iconCls : 'icon-add',
										handler : function() {
										var new_win = window.open("<c:url value='/jsp/openIndexSun.jsp?url=/customer/preAddCustomer.do'/>","sun","width=1200px,height=600px,status=no,scrollbars=yes");
										new_win.focus();
										$('#'+listDisplayEId).datagrid('reload');
										}
									},'-',
									{
										id : listDisplayEId + '_btn_edit',
										text : '修改',
										iconCls : 'icon-edit',
										handler : function() {
										
											var row = $('#'+listDisplayEId).datagrid('getSelections');
 											if(row.length == 0){
												$.messager.alert('提示','请选择一条记录操作！','info');
												return;
											}else{
												//window.showModalDialog("<c:url value='/customer/preUpdateCustomer.do'/>"+"?cifCusId="+row[0]['cifId'],"","dialogWidth=1200px;dialogHeight=900px,status=no");
												
												var new_win = window.open("<c:url value='/jsp/openIndexSun.jsp?url=/customer/preUpdateCustomer.do'/>","sun","width=1200px,height=600px,status=no,scrollbars=yes");
												new_win.focus();
												
												$('#'+listDisplayEId).datagrid('reload');
											}
											$('#'+listDisplayEId).datagrid('clearSelections');
										}
									}
									],
							onLoadError:function(){
								$.messager.alert('错误','获取数据失败，请与管理员联系！','error');
							} ,
							onClickRow:function(rowIndex){
								$(".myrad").prop("checked",false);
								$(".myrad").eq(rowIndex).prop("checked",true);
							} 
						});
			};
			
			function formatRadio(value,rowData,rowIndex){
				return value="<input type='radio' class='myrad'  name='radioCustomer' />";
			}
			
			$(document).ready(function() {
				initList('listDisplay');
				formatCombobox($("#gender"),"<%=path %>/querycode/listcode.do?codeTypeId=gender&mode=query");
				formatCombobox($("#certType"),"<%=path %>/querycode/listcode.do?codeTypeId=certificate_type&mode=query");
  			});
 
  	 
			
    function searchInfo(){
        var myurl = "<c:url value='/customer/findCustomer.do'/>";
    	 $('#searchForm').form('submit',
	 {	 
		url:myurl,
		onSubmit:function() 
		{
			return $('#searchForm').form('validate');
		},
		success:function(data){
			data = eval('(' + data + ')');
            if(data.success){
  	       		$('#listDisplay').datagrid('loadData',data);
	       		return;
       		}else{
       			$.messagerlert("", data.msg, 'warning');
	       		return;
       		}
		},
		error:function(){
			$.messager.alert("查询失败！", 'error');
			return;
		}
	});

}

			
		</script>
			</head>
			<body>
			<table >
			<tr>
			<td>
				<div style="height: auto;width:1180px; background: #fafafa; padding: 5px;" class="easyui-panel" title="客户查询" iconCls="icon-search" collapsible="true" minimizable="false" maximizable="false" closable="false" >
					<form id="searchForm" name="searchForm" method="post"
  						onsubmit="return searchDGData(this.id,'listDisplay');">
		             	<table >
		             	<tr>
		             	<td>
		             		姓名：
							<input type="text"  id="cusName" name="cusName"></input>
		             	</td>
		             	<td style="width: 10px"></td>
		             	<td>
						         性别：
							 <input class="easyui-combobox" style="width: 60px;" name="gender" id="gender">
		             	</td>
		             	<td style="width: 10px"></td>
		             		<td>
						           证件类型： 
							<input class="easyui-combobox" style="width: 80px;" id="certType" name="certType"></input>
							</td>
							<td style="width: 10px"></td>
							<td>
		                                                           证件号码： 
							<input type="text" id="certNo" name="certNo"></input>
							</td>
							<td style="width: 10px"></td>
							<td>
							CIFID：
							 <input class="easyui-numberbox" style="width: 80px;" id="cifId" precision="0" name="cifId"></input>
		             		</td>
		             		<td style="width: 10px"></td>
		             		<td><input type="button" onclick="searchInfo()" value="查询"></td>
		             		<td style="width: 10px"></td>
		             		<td><input type="button" value="客户导出" onclick="window.location.href='../../customer/customerListExcel.do'"></td>
		             	</tr>
		             	</table>
					</form>
				</div>
		</td>
		</tr>
		<tr style="height: 12px;"></tr>
		<tr>
		<td>
				<table id="listDisplay" title="客户列表" 
			iconCls="icon-list" singleSelect="true" idField="cifId"
			url="<c:url value="/customer/findCustomer.do"/>" loadMsg="请稍候......"
			pagination="true" pageSize="10"
			pageList="[10,20,30,40,50,100,150,200]" sortName="cifId"
			rownumbers="true" sortOrder="desc">
			<thead>
				<tr>
					<th field="radioRole" width="25" align="center" formatter="formatRadio"  >
				    <th field="cifId" width="100"  sortable="true" formatter="formatDGField" editor="text">
						CIFID
					</th>	
 					<th field="cusName" width="100" formatter="formatDGField" sortable="true" editor="text">
						姓名
					</th>
					<th field="gender" width="80" formatter="formatDGField" sortable="true" editor="text">
						性别
					</th>	
					<th field="certType" width="150" formatter="formatDGField" sortable="true" editor="text">
						证件类别
					</th>	
					<th field="certNo" width="150" formatter="formatDGField" sortable="true" editor="text">
						证件号码
					</th>				
					<th field="birthday" width="100" formatter="formatDGField" sortable="true" editor="text">
						出生日期
					</th>	
					<th field="insertTime" width="100" formatter="formatDGField" sortable="true" editor="text">
						创建日期
					</th>	
 				</tr>
			</thead>
			</table>
			</td>
			</tr>
			</table>
	</body>
</html>